home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / papers / pisces.ms < prev    next >
Text File  |  1991-09-04  |  45KB  |  810 lines

  1. .nr PS 10
  2. .nr VS 12
  3. .nr PD .7v
  4. .nr LL 6.5i
  5. .TL
  6. A Platform Independent Source Code Engineering System
  7. .AU
  8. Martin Neath
  9. neath@itg.ti.com
  10. .AI
  11. Texas Instruments Incorporated
  12. Information Technology Group
  13. Austin, TX
  14. .ND 
  15. .AB
  16. The Platform Independent Source Code Engineering System (PISCES) is an easy to
  17. use source code revision control, configuration, and automated make file system
  18. for use in large software projects. PISCES is a collection of several public
  19. domain utilities modified to work closely together to provide the software
  20. engineer with tools to simplify the process of rapidly porting and maintaining
  21. a C/C++ source code base across heterogenous hardware platforms and software
  22. environments.  This paper describes PISCES, presents a software methodology
  23. development model for structuring and maintaining a source code base, discusses
  24. the major components and how they have been modified to closely cooperate with
  25. each other, and provides an introduction to its use through several annotated
  26. examples.
  27. .AE
  28. .NH 1
  29. Introduction
  30. .LP
  31. The Platform Independent Source Code Engineering System (PISCES) is a
  32. collection of utilities providing a platform-independent source code revision
  33. control, configuration, and automated make file system. It is designed to be
  34. used by engineers on large software projects to control the complexities of
  35. source file dependencies and make file systems across heterogenous hardware
  36. platforms and operating system environments. PISCES is built upon the Revision
  37. Control System (RCS), the macro-make file facility (imake), an
  38. automatic file dependency list generator (mkdepend), the DECUS ANSI C
  39. preprocessor (cpp), and the GNU file differentiator program (diff).
  40.  
  41. The immediate impetus for creating PISCES was to ease the process of porting
  42. and maintaining a large software project written in C and C++ running on SPARC
  43. work stations, a MIPS Ultrix file server, a large VAX VMS system, and PS/2 (TM) 
  44. .FS
  45. PS/2 is a trademark of International Business Machines Corporation.
  46. .FE
  47. personal computers running either SCO UNIX\(rg
  48. .FS
  49. UNIX is a registered trademark of AT&T.
  50. .FE
  51. or IBM\(rg 
  52. .FS
  53. IBM is a registered trademark of International Business Machines Corporation.
  54. .FE
  55. OS/2 (TM)
  56. .FS
  57. OS/2 is a trademark of International Business Machines Corporation.
  58. .FE
  59. Extended Edition. Our software methodology requirements established the need
  60. for a revision control system with support for versioning and strict file
  61. locking, a make facility to control the build procedure that gives us a high
  62. degree of confidence in file dependency detection and automatic updates, and an
  63. easy means for recursively performing maintenance tasks and rebuilding and
  64. running regression test suites.  We examined the native tools available on each
  65. target platform and found varying levels of support for each of these tasks. No
  66. single platform, however, provided all the desired functionality and no two
  67. systems were consistent in either the programmer or command line interface.
  68.  
  69. As a result, we developed PISCES to allow the programmer to have a consistent
  70. interface to a common suite of tools providing powerful source code
  71. manipulation and configuration functions across very different platforms.
  72. These tools are all written in C and "glued" together through a single software
  73. methodology with an expected behavior utilizing machine independent macros and
  74. machine-specific command names and arguments. The modifications made to the
  75. public domain utilities are largely centered around removing any operating
  76. system bias towards UNIX, completely parameterizing all pathname determination
  77. and construction, and allowing for the joint development of both C and C++
  78. object files in a single environment. 
  79.  
  80. PISCES does not have infinite flexibility or the capability to solve very
  81. complex configuration problems. Rather, it is a simple-to-use collection of
  82. tools ideal for the 90% of configuration and build operations centered around
  83. construction of C and C++ object files, libraries, and programs on diverse
  84. hardware and software platforms. This paper describes PISCES, presents a
  85. software methodology development model for structuring and maintaining a source
  86. code base, briefly discusses the major components and the modifications made to
  87. each, examines the supported rules and actions for program development,
  88. provides an introduction to its use through several annotated examples, and
  89. lists the requirements and procedure for adding support for a new hardware
  90. platform or operating system.
  91. .NH 1
  92. Supported Hardware Platforms, Operating Systems, and Compilers
  93. .LP
  94. In order to be a useful and valueable tool, PISCES must run on several major
  95. hardware platforms and software environments.  Since our immediate goal was to
  96. enable the development and configuration of a large C and C++ project on
  97. several different machines, we identified the following six hardware platforms
  98. and associated operating systems and language facilities as the minimal
  99. required environments on which PISCES should be available and supported:
  100. .ID
  101. \(bu SUN SPARC supporting SunOS(TM) C and the AT&T C++ translator
  102. .FS
  103. SunOS is a trademark of Sun Microsystems, Inc.
  104. .FE
  105. \(bu DEC VAX/VMS supporting VAX C and the Oasys C++ language system
  106. \(bu DEC MIPS/Ultrix supporting Ultrix C and the AT&T C++ translator
  107. \(bu TI S1500 supporting GNU C and the AT&T C++ translator
  108. \(bu IBM PS/2 running OS/2 EE with IBM C/2(TM) or Microsoft\(rg C, and Glockenspiel C++
  109. .FS
  110. Microsoft is a registered trademark of the Microsoft Corporation.
  111. .FE
  112. \(bu Intel 386/486 platforms supporting SCO UNIX/C and Glockenspiel C++
  113. .FS
  114. C/2 is a trademark of International Business Machines Corporation.
  115. .FE
  116. .DE
  117. The various UNIX environments are fairly similar and represent
  118. relatively easy platforms to support. The VMS and OS/2 systems, however, are
  119. quite different in nature and organization and, in places, were difficult to
  120. support.  Since portability and identical functionality are important PISCES
  121. attributes, we have restricted or limited those operations and features that
  122. cannot be easily supported on all environments in an identical way. Adding
  123. support for another hardware platform or operating system and identifying the
  124. operations and functionality required is discussed later in this paper in the
  125. section, Extending PISCES to Additional Platforms and Environments.
  126. .NH 1
  127. The PISCES Source Code Engineering Methodology
  128. .LP
  129. The source code engineering methodology behind PISCES is nothing fundamentally
  130. new or revolutionary. Rather, it is a combination of common sense and ideas
  131. based upon the experience of many people in building real-world applications on
  132. several different types of hardware platforms. We identified the most important
  133. features and typical problem areas common in large software projects in order
  134. to try to put together a system to efficiently handle them. As engineers, we
  135. did not want to be hampered by a large and obtrusive mechanism that would be
  136. bypassed and ultimately wither except for the dictate of a manager. On the
  137. other hand, having seen many of the problems first hand, we realized that a 
  138. solution would probably require the imposition of some structure and 
  139. organization. Thus, the PISCES source code engineering methodology addresses
  140. the following points:
  141. .ID
  142. \(bu Directory structure and organization
  143. \(bu Source code control and revision system 
  144. \(bu Isolation of machine and operating system dependencies
  145. \(bu Unit and system level regression test code
  146. .DE
  147. .NH 2
  148. Directory Structure and Organization
  149. .LP 1
  150. A large software product can typically have hundreds of header and source
  151. files. As a result, nested subdirectories should be used to organize the files
  152. and simplify the understanding of related components through association in the
  153. same module. PISCES supports nested and recursive subdirectory make file
  154. invocation for all development activities though a single statement. A build
  155. activity can be activated at the top of the source tree, in which case all
  156. subdirectories will be affected. Alternately, a single subdirectory at some
  157. intermediate point in the source tree can be worked with independently.
  158. Finally, an operation can be performed on the files in the current directory,
  159. with subdirectories below subsequently processed for the same operation.
  160. .NH 2
  161. Source Code Control and Revision System
  162. .LP 1
  163. We strongly believe that all software systems should be developed and
  164. maintained within the structure of a source code control and revision system.
  165. PISCES uses RCS and automatically generates rules and dependency lists to
  166. support this system. As engineers, however, we strongly recognize the way in
  167. which such a system can hamper the productivity of a programmer who is forced
  168. to go through bureaucratic approval measures just to change a comment or make a
  169. minor change.  As a result, PISCES makes use of the distinction between major
  170. and minor revision numbers supported by RCS. A major revision number precedes
  171. the decimal point; a minor revision number follows the decimal point. Thus, a
  172. file with revision 3.27 would indicate minor revision 27 after the third major
  173. revision level starting source base.
  174.  
  175. Major revision numbers should mirror significant functionality changes,
  176. completion of milestones, or releases to beta sites and customers. These can
  177. and should be strictly controlled by a project manager or leader. Minor
  178. revision numbers, on the other hand, should identify intermediate check points
  179. for source code modifications made by the engineering team between major
  180. revision levels. This offers the benefit of a frequent and traceable change
  181. history without the burdens and overhead of approval cycles and paperwork. When
  182. a source code base is "reved-up" to the next major revision number, all files
  183. in the system are automatically incremented to the next revision, whether or
  184. not there has been a change. PISCES generates rules in the make file to allow
  185. past major revision levels to be built, thus allowing a single source base to
  186. be used for both supporting older versions of software as well as maintaining
  187. the current version.
  188. .NH 2
  189. Isolation of Machine and Operating System Dependencies
  190. .LP1 
  191. The key motivation for PISCES is portability across heterogenous hardware and
  192. software platforms. As a result, we assume that a large portion of the source
  193. code for this system is machine independent. Thus, most source code files are
  194. located in the main module subdirectories. Nevertheless, the necessity for
  195. machine and operating system specific code is a common requirement for
  196. efficient, complex applications. However, the use of many #ifdef statements to
  197. handle such machine dependencies is strongly cautioned against. It is our
  198. belief that #ifdef statements should be used to identify and handle very minor
  199. differences across platforms, for example the inclusion of function prototypes
  200. for ANSI C compliant compilers or the identification of a missing function in a
  201. standard header file for a particular operating system. Significant
  202. differences, such as pathname construction/parsing or memory allocation
  203. schemes, should be isolated in a machine-specific subdirectory whose name is
  204. the same as that used in PISCES. The following platform names are currently
  205. defined:
  206. .DS I
  207. mips        -- DEC/MIPS workstation running Ultrix
  208. sparc        -- Sun SPARC workstation running SunOS
  209. vms        -- DEC VAX machine running VMS
  210. sco386    -- Intel 80386 platform running SCO Unix
  211. os2        -- PS/2 running IBM OS/2 extended edition
  212. ti1500    -- TI S1500 running TI System V
  213. .DE
  214. Thus, a software subdirectory structure would have at or near the top level a
  215. machine subdirectory that contained an Imakefile and subdirectories whose name
  216. is the name of a particular PISCES-supported platform. When a software system
  217. is built, only that subdirectory whose name matches the system-type name
  218. defined in the top level Imakefile is built. Other platform subdirectories
  219. remain untouched.  This isolation organization has two benefits. First, when
  220. porting a software source base to a new platform, most if not all
  221. machine-specific functionality is already identified.  Second, the remaining
  222. source code is relatively uncluttered with #ifdef statements, thus making for a
  223. more readable and understandable source code base.
  224. .NH 2
  225. Unit and System Level Regression Test Code
  226. .LP 1
  227. We believe the importance of unit-level and system regression test code cannot
  228. be stated strongly enough. Individual members of a project should spend a
  229. significant portion of their time writing unit-level test code for the areas
  230. and modules for which they are responsible. System level test code should be
  231. coordinated by a full time software quality engineer and every project member
  232. should participate in its design and development. The PISCES rules and actions
  233. support a system-level test code subdirectory and unit-level test code
  234. subdirectories below each module subdirectory. Specific rules to build the test
  235. code and run regression tests are directly supported and automatically inserted
  236. into a generated make file.
  237. .NH 1
  238. The PISCES Components
  239. .LP
  240. PISCES consists of the following five components: the Revision Control System
  241. (RCS), the macro-make file facility (imake), an automatic file dependency list
  242. generator (mkdepend), the DECUS ANSI C preprocessor, and the GNU diff program.
  243. All components are available in the public domain with no fees or royalities
  244. attached. In addition, all are written in C and of exceptional high quality.
  245. Although some of these components are typically available on an individual
  246. system, we decided to use the PISCES versions in all cases so as to assure the
  247. same interface, functionality, and features across all platforms. We believe
  248. that PISCES should be made available in the public domain for others who might
  249. find it useful. The following sections briefly discuss each component and 
  250. identify modifications and changes made to implement PISCES on all platforms.
  251. .NH 2
  252. The Macro Make Facility (imake)
  253. .LP
  254. Imake is a tool available on many UNIX platforms that assists with the task of
  255. building a software system consisting of many files with a large number of
  256. dependencies.  Imake was originally developed by Todd Brunhoff for the MIT X11
  257. source distribution as a utility to simplify the process of configuring
  258. and building the X window system on various flavors of UNIX[1]. Imake uses the C
  259. preprocessor on a macro-makefile (the Imake file) to generate a make file for a
  260. particular system.  Imake uses a predefined template file for default values
  261. and commands, a site file for system-specific pathnames and idiosyncracies, a
  262. project file for project-specific command names and procedures, and a set of
  263. support macros for tying everything together.  An Imake file is
  264. system-independent; support for a new operating system or platform requires
  265. only the addition of a template file for that system.  The Imake file 
  266. specifying the dependencies and relationships between files in the software
  267. system to be built does not change.  This allows machine dependencies (such has
  268. compiler options, alternate command names, and special make rules) to be kept
  269. separate from the descriptions of the various items to be built.
  270.  
  271. As available on the X11R4 source tape, Imake provides support for a number of
  272. UNIX-based platforms and environments to ease the building of X on a particular
  273. system[2]. However, Imake makes several assumptions about the platform on which
  274. it is being run, the most obvious of which are pathname
  275. construction/manipulation, the existence of a named pipes facility, and the
  276. availability and location of a C preprocessor. In addition, the collection of
  277. macros provided is both X- and UNIX-specific in nature and confusing to the
  278. novice user. As such, it is unsuitable for use on such platforms as OS/2 and
  279. VMS or in situations where the programmer is not an expert on the intricacies
  280. of a C preprocessor and the UNIX operating system. The PISCES version of Imake
  281. makes no such assumptions and has been rewritten to use "plain vanilla" C code
  282. that can be compiled and executed on most systems with a C compiler. In
  283. addition, the macros used by a programmer in an Imakefile have been simplified
  284. and restructured to provide support for simultaneous development of both C and
  285. C++ object files, parameterized pathname syntax and construction, and removal
  286. of operating system and X-specific features such as shared libraries and
  287. server/client operations.
  288.  
  289. Two other significant modification made to Imake for PISCES are the addition of
  290. several special characters used to represent certain behavior and the shortened
  291. file names of the various imake configuration files. Due to the behavior and
  292. idiosyncracies of the C preprocessor, Imake uses the character strings "@@\\"
  293. to indicate a continuation line in an Imake rule, "@+" and "@-" to indicate
  294. that Imake should increment or decrement, respectively, the immediately
  295. following number, "@!" to indicate that a string should be quoted as
  296. appropriate for a particular operating system, and "@#" to indicate that a line
  297. is a make file comment line. The names of the Imake configuration files have
  298. been modified to make them portable to non-UNIX platforms. The file names are
  299. listed below, with the modified name shown on the left and the original X11R4
  300. file name given on the right:
  301. .DS I
  302. copyrite.imk            <no equivalent file>
  303. \fIplatform.cf\fR                <platform configuration file>
  304. site.imk                site.def
  305. project.imk                Project.tmpl
  306. imake.imk                Imake.tmpl
  307. imake.rul                Imake.rules
  308. .DE
  309. The first file inserts a company-specific copyright notice into each generated
  310. make file. The second file is the platform-specific configuration file to
  311. override default PISCES commands and macros. The third file allows for
  312. specification of any site parameters, such as the location of the
  313. standard C and C++ header files. The fourth contains file names, pathnames, and
  314. other application-specific information. The fifth is the generic Imake template
  315. that controls the order and type of information used to create a make file. The
  316. last contains the default Imake rules and macros. When Imake is run, it
  317. searches for these files along the include path search directories, looking
  318. first in the top level project subdirectory and then in the main PISCES
  319. configuration directory.
  320. .NH 2
  321. The Automatic File Dependency Generator (mkdepend)
  322. .LP
  323. The make depend utility on the X11R4 source tape is associated with Imake 
  324. and follows the include statements through each source file to determine all
  325. other files in the system that each is dependent upon. This dependency list is
  326. then appended to the generated make file so that if one or more dependent files
  327. are modified, the affected source file can be recompiled accordingly. As with
  328. Imake, however, there are a number of assumptions about the system and the 
  329. nature of the dependencies, particularly concerning pathname construction,
  330. file name extensions, and the structure of the dependency list.
  331.  
  332. The PISCES version of mkdepend performs the same operation as the original
  333. version, but does so in a more platform independent manner. In addition to
  334. changes necessary to allow for compilation and execution on all hardware
  335. platforms and software environments, the most significant modification made is
  336. the manner in which pathnames are constructed and manipulated. In
  337. particular, several additional command line options provide for specification
  338. of starting and ending pathname strings, support for generation of RCS
  339. dependencies, and the pathname separator character. Finally, assumptions and
  340. changes to file name extensions are made to allow dependency lists to be
  341. created for RCS, header, C source, C++ source, and object files. Control and
  342. invocation of mkdepend is handled by Imake and is completely hidden from the
  343. programmer.
  344. .NH 2
  345. The DECUS ANSI C Preprocessor (cpp)
  346. .LP
  347. Many C and C++ language implementations separate the preprocessor and compiler
  348. functions. Others, (such as the Glockenspiel C++ language system or the IBM C/2
  349. compiler), combine the preprocessor and compiler into one step. Since we needed
  350. a portable utility to massage macro make files that works under both scenarios,
  351. we decided to select an ANSI C-preprocessor that could be included as part of
  352. the PISCES tool set. Thus, the PISCES preprocessor is derived from and based
  353. upon a public domain C-preprocessor (the DECUS C preprocessor) made available
  354. by the DEC User's group and supplied on the X11R3 source tape from MIT. It has
  355. been modified to run on each of the target platforms and to comply with the
  356. draft ANSI C specification[3] with the exception that trigraph sequences are
  357. not supported.
  358. .NH 2
  359. The Revision Control System and File Differentiator (RCS and diff)
  360. .LP
  361. The Revision Control System (RCS) is a software tool written by Walter F. Tichy
  362. at the Department of Computer Sciences at Purdue University available on a wide
  363. variety of UNIX systems that assists with the task of keeping a software system
  364. consisting of many versions and configurations well organized[4].  Widely
  365. considered to be an efficient next-generation source control system to the
  366. popular SCCS, RCS manages revisions of text documents, in particular source
  367. programs, documentation, and test data in a space and time efficient manner.
  368. It automates the storing, retrieval, logging and identification of revisions,
  369. and it provides selection mechanisms for composing configurations.  For
  370. conserving space, RCS stores deltas, i.e., differences between successive
  371. revisions. The RCS file format is ASCII text, portable from one system to
  372. another. Thus, an RCS file containing versions of a file created and edited on
  373. a UNIX system can be used on a VMS system with no conversion.
  374.  
  375. Version control is the task of keeping software systems consisting of many
  376. versions and configurations well organized.  RCS is a set of commands that
  377. assist with that task.  RCS' primary function is to manage revision groups.  A
  378. revision group is a set of text documents, called revisions, that evolved from
  379. each other.  A new revision is created by manually editing an existing one.
  380. RCS organizes the revisions into an ancestral tree.  The initial revision is
  381. the root of the tree, and the tree edges indicate from which revision a given
  382. one evolved.  Besides managing individual revision groups, RCS provides
  383. flexible selection functions for composing configurations. RCS supports both
  384. major and minor revision levels. Typically, major revision numbers are for
  385. significant changes/updates or release versions. Minor revision numbers are
  386. used when making incremental changes that are limited in scope and nature.
  387.  
  388. RCS also offers facilities for merging divergent versions of a common file and
  389. for automatic identification.  Identification is the `stamping' of revisions
  390. and configurations with unique markers.  These markers are akin to serial
  391. numbers, telling software maintainers unambiguously which configuration is
  392. before them. The merge capability allows two different but ancestorally related
  393. versions of a file to be merged so long as there are no competing changes and
  394. conflicts. This allows two engineers to each modify a different function in a
  395. source file implementing two functions.  When each has finished modifying their
  396. respective function, the files can be merged to restore the single source file
  397. reflecting the changes made by each.  The RCS merge capability requires a file
  398. differentiator tool for identifying the differences between two files. The GNU
  399. diff program is used as a portable and efficient tool for this purpose.
  400.  
  401. The PISCES versions of RCS and diff are functionally unaltered from their 
  402. original UNIX implementations. Changes necessary to each were largely
  403. restrained to file names and extensions, examination of date/time stamps, and
  404. file reading and writing operations.
  405. .NH 1
  406. Installing and Bootstrapping PISCES
  407. .LP
  408. When first installed on a new system, the PISCES components must be
  409. bootstrapped by a system administrator or programmer. This typically requires
  410. access to system subdirectories and knowledge of system configuration,
  411. compilation, and installation procedures. The minimal PISCES components require
  412. no special compilation procedure. Each component is in
  413. its own subdirectory, with source and header files are under RCS control. A
  414. checked out version of each file is provided for bootstrapping purposes. The
  415. components should be built in the following order: cpp, imake, and mkdepend.
  416. Once complete, the minimal required components are available with
  417. which to build the trickier RCS and diff utilities. Finally, rebuild all PISCES
  418. components with themselves using the supplied Imake files to insure that
  419. everything is working correctly. Complete documentation and details for each
  420. platform can be found in the README file in the top level PISCES subdirectory.
  421. .NH 1
  422. PISCES Rules and Variables
  423. .LP
  424. A programmer controls the actions to be taken in an Imake file by using the
  425. PISCES rules defined as preprocessor macros in the Imake project, site,
  426. template, and configuration files. There are approximately 60 such macros
  427. defined, of which only a small number are actually used by the end-user
  428. programmer. Most are macros used internally for breaking down and structuring
  429. the actions supported by other higher-levels macros. An Imakefile contains 
  430. calls to several of these higher-level macros to define the following items:
  431. .DS I
  432. \(bu optional top level and subdirectory specifications
  433. \(bu a required main or top level target/action
  434. \(bu a required list of header, source, and object files
  435. \(bu one or more required compilation rules
  436. \(bu one or more required program or library targets
  437. \(bu optional header and regression test operations
  438. .DE
  439. The most commonly used macros control basic operations such as selecting the
  440. type of object file to produce, specifying library, program, and directory
  441. names, and building programs. The best way to become familliar with these
  442. macros is to look at the examples in the tutorial below and study the results
  443. in the generated make file. The following
  444. list of macros identifies the main rules used by most engineers using PISCES:
  445. .DS I
  446. All()                        - Simple target
  447. All[1-24]()                    - Simple target
  448. LinkIncludes(files)            - Link headers to $(INCDIR)
  449. NormalCObject()                - Normal C compile rule
  450. NormalCPlusObject()            - Normal C++ compile rule
  451. DebugCObject()                - Debug C compile rule
  452. DebugCPlusObject()            - Debug C++ compile rule
  453. TestCObject()                - Test code C compile rule
  454. TestCPlusObject()                - Test code C++ compile rule
  455. OptimizeCObject()            - Optimize C compile rule
  456. OptimizeCPlusObject()            - Optimize C++ compile rule
  457. LibraryName(name)            - Add/Update $(OBJS) to library
  458. QuoteName(name)            - Add quotes around file name
  459. VersionName()                - Generate RCS version name
  460. Clobber()                    - Remove object/scratch files
  461. Clean()                    - Delete objects
  462. RCSCheckOut()                - Checkout files from RCS 
  463. Test()                        - Compile and run regression tests
  464. Test[1-24]()                    - Compile and run regression tests
  465. CLexScanner(scanner)            - User-level LEX rule (C compatible)
  466. CYaccParser(parser)            - User-level YACC rule (C compatible
  467. CPlusLexScanner(scanner)        - User-level LEX rule (C++ compatible)
  468. CPlusYaccParser(parser)        - User-level YACC rule (C++ compatible
  469. CProgram(program)            - Link objects into C program 
  470. CProgram[1-24](program)        - Link objects into C program 
  471. AuxillaryCProgram(program)        - Additional C program rule
  472. CPlusProgram(program)            - Link objects into C++ program
  473. CPlusProgram[1-24](program)        - Link objects into C++ program
  474. AuxillaryCPlusProgram(program)    - Additional C++ program rule
  475. TopLevelBootStrap()            - Bootstrap Imake from top level directory
  476. .DE
  477. Each macro performs an operation or set of functions for a given target. When
  478. an operation is complete in the current directory level, the same operation is
  479. recursively performed on subdirectories if appropriate. The versions of macros
  480. with the number one through twenty four enclosed with brackets allow for the
  481. specification of up to 24 separate programs in a single Imake file. If there
  482. are three related C++ programs in a single Imake file, the programmer would use
  483. the \fBAll3()\fR and \fBCPlusProgram3()\fR macros with the appropriate
  484. arguments. See example two below for more details. If you wish to add rules or
  485. procedures of your own for a specific project file to the collection of Imake
  486. rules, examine the macro definitions and the use of the special Imake command
  487. characters in the Imake rules file \fBimake.rul\fR located in the PISCES
  488. configuration subdirectory.
  489.  
  490. In addition to using PISCES rules, a programmer often needs to set or override
  491. system, project, or local values for preprocessor definitions, include search
  492. directory paths, and libraries.  The following list of variables identifies the
  493. common variables most often needed by engineers using PISCES:
  494. .DS I
  495. STD_C_INCS                - Standard C include search directories       
  496. STD_C_DEFS                - Standard C command line symbol definitions  
  497. STD_C_LIBS                - Standard C archive libraries                
  498. STD_C_LIBDIRS                - Standard C library search directories       
  499. STD_CPLUS_INCS            - Standard C++ include search directories     
  500. STD_CPLUS_DEFS            - Standard C++ command line symbol definitions
  501. STD_CPLUS_LIBS            - Standard C++ archive libraries              
  502. STD_CPLUS_LIBDIRS            - Standard C++ library search directories     
  503. PROJECT_C_INCS            - Project C include search directories       
  504. PROJECT_C_DEFS            - Project C command line symbol definitions  
  505. PROJECT_C_LIBS            - Project C archive libraries                
  506. PROJECT_C_LIBDIRS            - Project C library search directories       
  507. PROJECT_CPLUS_INCS        - Project C++ include search directories     
  508. PROJECT_CPLUS_DEFS        - Project C++ command line symbol definitions
  509. PROJECT_CPLUS_LIBS        - Project C++ archive libraries              
  510. PROJECT_CPLUS_LIBDIRS        - Project C++ library search directories     
  511. LOCAL_C_INCS                - Local C include search directories       
  512. LOCAL_C_DEFS                - Local C command line symbol definitions  
  513. LOCAL_C_LIBS                - Local C archive libraries                
  514. LOCAL_C_LIBDIRS            - Local C library search directories       
  515. LOCAL_CPLUS_INCS            - Local C++ include search directories     
  516. LOCAL_CPLUS_DEFS            - Local C++ command line symbol definitions
  517. LOCAL_CPLUS_LIBS            - Local C++ archive libraries              
  518. LOCAL_CPLUS_LIBDIRS        - Local C++ library search directories     
  519. .DE
  520. Each variable controls the value of a specific option at compile or link time.
  521. Note that there exists a version of each variable for both C and C++ for the
  522. standard, project, and local values. The PISCES macros and variables are more
  523. fully explained in the following section, A PISCES Tutorial.
  524. .NH 1
  525. A PISCES Tutorial
  526. .LP
  527. Most source code configuration problems follow one of a few patterns: compiling
  528. one or more source code files to be linked together to create a program; 
  529. compiling one or more source code files to be archived in a library; creating
  530. one or more programs comprised of source code in one or more subdirectory
  531. modules; various maintenance activites such as cleaning up work files, running
  532. regression tests, or removing all object files and executables. This tutorial
  533. looks at several of these cases and discusses the flexibility and ordering
  534. of PISCES rules in an Imake file.
  535. .NH 2
  536. Example 1: A Simple C Program
  537. .LP 1
  538. Suppose you want to make the C program \fBprog\fR by compiling the three
  539. three source files \fBfile1.c\fR, \fBfile2.c\fR, and \fBfile3.c\fR and linking
  540. the resulting object files together with the standard C runtime library. The
  541. following PISCES Imake file could be used:
  542. .DS I
  543. HDRS =
  544. SRCS = file1.c file2.c file3.c
  545. OBJS = file1.o file2.o file3.o
  546. All(prog)
  547. OptimizeCObject()
  548. CProgram(prog)
  549. .DE
  550. Lines one through three identify the header, source, and object files for the
  551. program. Notice that although there are no program-specific header files, we
  552. nevertheless include an empty definition. Line four identifies the main or
  553. top-level target. For historical reasons, this is given the label `all' in the
  554. generated make file. Line five indicates that we want Imake to generate
  555. commands to create optimized C object files. Other possible choices are for
  556. standard and debug versions of C object files, in addition to the three
  557. analagous C++ object files. The last line generates commands to check out
  558. source code from RCS, compile, link, clean, and install the program.
  559. All program names, command line options, and procedures for the various phases
  560. of this process are hidden in the generic template file, optional project and
  561. site files, and the machine-specific configuration file.
  562. .NH 2
  563. Example 2: Multiple C++ Programs 
  564. .LP 1
  565. In this slightly more complicated example, there are two C++ programs each
  566. comprised of several source files. The second program has an associated header
  567. file and all source files are compiled with a command line definition for a
  568. symbol. The first program, \fBfoo\fR, is made from the source files 
  569. \fBfile1.C\fR, \fBfile2.C\fR, and \fBfile3.C\fR. The second program is made
  570. from the source files \fBfile3.C\fR and \fBfile4.C\fR. The following PISCES
  571. Imake file controls their construction:
  572. .DS I
  573. HDRS1 =
  574. HDRS2 = foo.h
  575. SRCS1 = file1.C file2.C file3.C
  576. SRCS2 = file3.C file4.C
  577. OBJS1 = file1.o file2.o file3.o
  578. OBJS2 = file3.o file4.o
  579. STD_CPLUS_DEFS = $(DFLAG)COMPANY=$(QUOTE)ABC Plumbing$(QUOTE)
  580. All2(foo,bar)
  581. OptimizeCPlusObject()
  582. CPlusProgram1(foo)
  583. CPlusProgram2(bar)
  584. .DE
  585. Lines one through six list the header, source, and object files for each
  586. program. There is one header file used by the second program and there are four
  587. C++ source files, one of which is used in both programs. Line seven defines a
  588. command line preprocessor symbol whose value is the character string "ABC
  589. Plumbing".  Note that due to operating system differences, the command line
  590. "define" option and the mechanism for quoting the string are themselves macros.
  591. Line eight identifies the main targets, \fBfoo\fR and \fBbar\fR, for the
  592. `all' label. Line nine specifies that the program should be built from
  593. optimized C++ object files.  Finally, lines ten and eleven generate the
  594. commands to checkout out source code from RCS, compile, link, clean, and
  595. install the two programs. As currently implemented, PISCES will allow a single
  596. Imake file to contain targets for upto 24 independent programs. This is
  597. accomplished by using the \fBHDRS\fR, \fBSRCS\fR, \fBOBJS\fR, \fBAll\fR,
  598. \fBCProgram\fR, and \fBCPlusProgram\fR rules appended with the program number.
  599. In addition, library archives and/or program specifications can intermix C and
  600. C++ source and object files as necessary.
  601. .NH 2
  602. Example 3: A Library Archive With Yacc/Lex Dependents
  603. .LP 1
  604. In this last example, two C++ source files \fBfile1.C\fR and \fBfile2.C\fR
  605. are compiled with debug flags on and added to an application library. In
  606. addition, scanner and parser object files are also added to the library. The
  607. following PISCES Imake file controls this operation:
  608. .DS I
  609. HDRS = program.h
  610. SRCS = file1.C file2.C
  611. OBJS = file1.o file2.o my_lex.o my_yacc.o
  612. LEXSRC = lexer1.l lexer2.l
  613. YACCSRC = decl.y tokens.y rules.y
  614. All($(LIBRARY))
  615. DebugCPlusObject()
  616. OptimizeCObject()
  617. LinkIncludes($(HDRS))
  618. Library($(LIBRARY),$(OBJS))
  619. CLexScanner(my_lex)
  620. CYaccParser(my_yacc)
  621. .DE
  622. Lines one through three list the header, source, and object files. Lines four
  623. and five list the scanner and parser modules that, when concatenated together,
  624. processed, and compiled, produce the \fBmy_lex.o\fR and \fBmy_yacc.o\fR object
  625. files. Line six specifies that the application library is the main make file
  626. target. The variable \fBLIBRARY\fR is specified in the project Imake file.
  627. Lines seven and eight indicate that the C compiler should generate optimized
  628. object files and the C++ compiler generate object files with the debug flag and
  629. symbols enabled. Line nine states that the header file(s) specified should be
  630. linked to the main application include subdirectory. Line ten controls the
  631. creation and update of the local library should any of the object files be
  632. changed. Finally, lines eleven and twelve control the generation of the scanner
  633. and parser modules with C-linkage using the public domain programs flex and
  634. byacc*.
  635. .FS *
  636. Flex is a public domain fast lexical analyzer generator compatible with lex(1).
  637. It was written by Vern Paxson of Lawrence Berkeley Laboratory and placed in the
  638. public domain. Byacc is a public domain yacc(1) compatible parser generator
  639. from the USC Berkeley Computer Science Department. Both programs are supplied
  640. in source format in the PISCES subdirectory and compile/execute on the
  641. PISCES-supported platforms.
  642. .FE
  643. .NH 2
  644. Example 4: A Custom Imakefile For a Work Directory
  645. .LP 1
  646. So far, the discusion and examples in this paper have centered around project
  647. Imake files most often used in a batch mode or when rebuilding entire modules
  648. of a software system. Another common requirement is as a local Imake file in an
  649. engineers working subdirectory. Under this scenario, a programmer has several
  650. files that are undergoing modification. What is needed is a personalized Imake
  651. procedure that will allow for locally overriden values and alternatives to the
  652. default project and system variables. The following PISCES Imake file could
  653. control construction of several files in this manner:
  654. .DS I
  655. HDRS = foo.h
  656. SRCS = foo.C bar.C
  657. OBJS = foo.o bar.o
  658. RCSDEP = 
  659. LOCAL_INCS=$(IFLAG)$(HOME)
  660. LOCAL_CPLUS_LIBS=$(LIBSFLAG)my_lib
  661. LOCAL_CPLUS_LIBDIRS=$(LDIRFLAG)$(HOME)
  662. All(hacker)
  663. DebugCPlusObject()
  664. CPlusProgram(hacker)
  665. .DE
  666. As in the previous examples, the first three lines establish the names of the
  667. header, source, and object files that comprise the program. Lines four through
  668. seven is the heart of this example. By default, PISCES assumes all source and
  669. header files are kept under RCS and automatically generates rules to examine
  670. such dependencies and check out files accordingly. For local working
  671. directories where a file is still under development, this is probably not
  672. convenient. By overriding the value of the \fBRCSDEP\fR symbol as in line four,
  673. PISCES does \fInot\fR look for RCS files to examine dependencies and check out
  674. the latest version. Lines five through seven set
  675. values for the local variables controlling include search directory,
  676. library, and library search directory. As a result, PISCES generates a Makefile
  677. that will check for include files first in the directory specified by
  678. \fB$(HOME)\fR before checking the project and standard include search
  679. directories. In addition, references for unresolved symbols at link time will
  680. be first searched for in the \fBmy_lib\fR library archive before the project 
  681. and system archives are searched.
  682.  
  683. By default, the values of the local and project variables are empty. A project
  684. leader edits the project file in the top level project directory to establish
  685. default values for the project variables. An individual engineer can provide
  686. his/her own values for these variables in a local Imake file by setting 
  687. appropriate values as in the example above. In this manner, each engineer can
  688. configure Imake to work on Imake files while in a local development environment
  689. without affecting all other engineers on the project.
  690. .NH 1
  691. Using PISCES in the Software Development Process
  692. .LP
  693. After an Imake file is specified, the PISCES components can be used to create
  694. the machine-specific make file. Imake, the main program, requires four command
  695. line arguments: a preprocessor symbol identifying the machine type, another
  696. preprocessor symbol indicating the absolute pathname of the top level source
  697. directory for the software system being built, a revision number indicating the
  698. latest RCS major version number, and the include file search directory path in
  699. which to look for the Imake configuration files. On a UNIX platform, a typical
  700. startup command might be:
  701. .DS I
  702. % imake -Dsparc -DTOPDIR=/home/neath -DREV=1 -I/usr/local/bin/pisces
  703. .DE
  704. The machine name is used to select the appropriate command names and machine
  705. specific actions in the various configuration files. The RCS major revision 
  706. number controls the number and type of rules generated for building previous
  707. versions of the software. Once an initial top level make file has been
  708. bootstrapped, the remaining system make files and dependency lists must be
  709. created by specifying the `bootstrap' target to the make program. On a UNIX
  710. platform, this command would be:
  711. .DS I
  712. % make bootstrap
  713. .DE
  714. Note that this is a special top level command available available only if the
  715. statement `#define TopLevelImakeFile' is contained in the Imake file. After
  716. this step, the user need never use the Imake command again. All updates and
  717. modifications should be made to the Imake file, not the automatically generated
  718. make file. A new up-to-date make file can be created at anytime by specifying
  719. the `makefile' target to the make program. On a UNIX platform, this command
  720. would be:
  721. .DS I
  722. % make makefile
  723. .DE
  724. If the Imake file contains the statement `#define IHaveSubdirs' indicating the
  725. presence of subdirectories, new make files for all subdirectories can be
  726. generated by specifying the `makefiles' target. Other supported actions for a
  727. generated make file include all, checkout, install, clean, clobber, revup,
  728. test, and depend. Examine a PISCES-generated make file or refer to the example
  729. Imake files in the PISCES subdirectory for further details.
  730. .NH 1
  731. Extending PISCES to Additional Platforms and Environments
  732. .LP
  733. PISCES is intended to be a portable and dependable source code engineering
  734. system. As such, any system to which PISCES is ported should fully support all
  735. rules, actions, and behavior as on other existing platforms. This is necessary
  736. in order to insure that Imake files do not have to be altered from one platform
  737. to the next. To add support for another platform to those listed above, first
  738. compile and build the PISCES components. Next, add a machine-specific
  739. configuration file containing command names and/or equivalent functions as
  740. defined in the standard imake.imk template and imake.rul rules files. Since
  741. these files are included by Imake \fIafter\fR this configuration file,
  742. platform-specific macros and command names can override the default PISCES
  743. values.  Finally, modify the imake.imk template file to recognize the new
  744. machine type symbol and define the appropriate MacroFile symbol. Now rebuild
  745. the PISCES components using Imake to regenerate the make files and control the
  746. compilation process.
  747.  
  748. The difficulty of adding support for PISCES on additional operating systems and
  749. hardware platforms varies and cannot be predicted. Many UNIX-like operating
  750. systems should be fairly easy to support, but others may be quite difficult or
  751. even impossible. PISCES assumes that the system has a make facility with
  752. similar capabilities to the UNIX make(1) command. In addition, commands for
  753. compiling, copying and deleting files, and maintaining library archives are
  754. also necessary. Finally, memory availability may affect performance and even
  755. determine sucess or failure, particularly for operating systems with limited or
  756. non-virtual memory subsystems.
  757. .NH 1
  758. Conclusion
  759. .LP
  760. Texas Instruments is currently using PISCES on several large internal software 
  761. projects that require multi-platform deliverables. We have found it to be a
  762. great aid in rapidly porting and maintaining a source code base from one
  763. platform to another. In addition, we have found that the use of PISCES reduces
  764. the need for a programmer to be an "expert" on the use of system-specific
  765. utilities on several platforms, not to mention the avoidance of peculiarities
  766. and idiosyncracies of particular utilities, ie. the nature of space characters
  767. versus tab characters in make(1).
  768. .NH 1 
  769. Status of PISCES
  770. .LP
  771. PISCES is currently up and running on a Sun SPARCstation 1 (TM) 
  772. .FS
  773. SPARCstation 1 is a trademark of Sun Microsystems, Inc.
  774. .FE
  775. running SunOS 4.x and a VAX 5400 MIPS machine running Ultrix release 3.1. The
  776. ports for a VAX 8600 running VMS version 5.1 and a PS/2 model 70/486 running
  777. OS/2 1.2 Extended Edition are currently in progress. Ports for the TI S1500
  778. running TI System V and a PS/2 model 70/486 running SCO UNIX 2.3 will begin
  779. shortly.  The SPARC and MIPS ports support the AT&T C++ translator (cfront)
  780. version 2.0 and the native C compiler, the SCO UNIX and OS/2 ports support the
  781. Glockenspiel translator version 2.0 with the IBM C/2 or Microsoft C compiler
  782. version 6.0, and the VAX VMS port supports the Oasys C++ translator version 2.0
  783. and the native VAX C compiler.
  784. .NH 1
  785. References
  786. .IP [1]
  787. MIT X Consortium,
  788. .I
  789. Imake Configuration Guide,
  790. .R
  791. X11R4 Release Tape Documentation Notes
  792. .IP [2]
  793. Mark Moraes,
  794. .I
  795. An Imake Tutorial,
  796. .R
  797. Computer Systems Research Institute, University of Toronto.
  798. .IP [3]
  799. Brian Kernighan and Dennis Richie,
  800. .I
  801. The C Programming Language,
  802. .R
  803. Second Edition, Prentice-Hill, Englewood Cliffs, NJ, 1988.
  804. .IP [4]
  805. Walter F. Tichy,
  806. .I
  807. RCS - A System for Version Control,
  808. .R
  809. Department of Computer Sciences, Purdue University, West Lafayette, Indiana.
  810.